package kksoft.kkexpress;

import kksoft.kkexpress.executor.ExpressContext;
import kksoft.kkexpress.executor.ExpressExecutor;
import kksoft.kkexpress.resolver.ResolveContext;
import kksoft.kkexpress.resolver.ExpressResolver;

import java.io.IOException;

public class ExpressEngine {
    public Object eval(String script, ExpressContext context) throws IOException, ExpressException {
        ExpressResolver sr = new ExpressResolver();
        ResolveContext rc = sr.resolve(script);

        ExpressExecutor se = new ExpressExecutor(context, rc);
        se.exec();

        return rc.value;
    }
}
